// Copyright 2011 Jefferson Willian
// willmont7@gmail.com

#include <cstdio>
#include <map>

using std::map;

int main() {
  map<int, int> mymap;

  int n;
  int t;
  int higher;

  scanf("%d", &n);

  for (int i = 0;i < n;i++) {
    scanf("%d", &t);
    if (mymap.find(t) != mymap.end())
      mymap[t]++;
    else
      mymap[t] = 1;
    if (mymap[t] > mymap[higher])
      higher = t;
  }

  printf("%d\n", higher);

  return 0;
}
